#ifndef _LJMU_DX_MANAGER_H_
#define _LJMU_DX_MANAGER_H_

//Include the Header Files For Direct 3D 10 and the Direct 3D 10 X Support Libraries
#include <d3d10.h>
#include <d3dx10.h>
#include <d3dx10math.h>
#include "cljmudx10winapp.h"

/****************************************
* This class is our manager for Direct X,
* and is used to handle all contact with
* The main elements of the Direct X 10 
* API.
* AUTHOR:   CHRIS CARTER
****************************************/
class CDX10Manager
{
public:
	//---------------CONSTRUCTORS AND DESTRUCTORS--------------------------------------
	CDX10Manager(CDX10WindowsApplication* pwndapp): _obj_wnd_app(pwndapp),_obj_dx_device(NULL),_obj_dx_swapchain(NULL),
											_obj_rdr_tgt_view(NULL),_obj_depth_stencil_buff(NULL),_obj_depth_stencil_state(NULL),
											_obj_depth_stencil_view(NULL),_obj_raster_state(NULL),_obj_depth_stencil_state_off(NULL)
											{}
	
	~CDX10Manager(){}

	//---------------ACCESSORS/MUTATORS------------------------------------------------
	ID3D10Device*					getDX10Device();
	IDXGISwapChain*					getDX10SwapChain();
	ID3D10RenderTargetView*			getBackBuffer();
	ID3D10Texture2D*				getDSBuffer();
	ID3D10DepthStencilView*			getDSView();
	ID3D10RasterizerState*			getRasteriserState();
	void							storeGPUInfo(char* pgpuname, int& pstore);

	//---------------PUBLIC METHODS----------------------------------------------------
	bool initialise();
	void cleanup();

	void beginRendering();
	void endRendering();
	void disableTwoDimMode();
	void enableTwoDimMode();
	
private:
	//---------------INTERNAL FIELDS----------------------------------------------------
	//Standard Data Type Properties
	int							_prop_gpu_mem;
	char						_prop_gpu_desc[128];

	//Direct X 10 Objects
	IDXGISwapChain*				_obj_dx_swapchain;
	ID3D10Device*				_obj_dx_device;
	ID3D10RenderTargetView*		_obj_rdr_tgt_view;
	ID3D10Texture2D*			_obj_depth_stencil_buff;
	ID3D10DepthStencilState*	_obj_depth_stencil_state;
	ID3D10DepthStencilState*	_obj_depth_stencil_state_off;
	ID3D10DepthStencilView*		_obj_depth_stencil_view;
	ID3D10RasterizerState*		_obj_raster_state;
	CDX10WindowsApplication*	_obj_wnd_app;	
};

//----------------INLINE GETTERS AND SETTERS----------------------------------------------------------

/******************************************
* Return the Pointer to the D3D10 Device Object
******************************************/
inline ID3D10Device* CDX10Manager::getDX10Device()
{
	return this->_obj_dx_device;
}

/******************************************
* Return the Pointer to the DX10 Swap Chain.
******************************************/
inline IDXGISwapChain*	CDX10Manager::getDX10SwapChain()
{
	return this->_obj_dx_swapchain;
}

/******************************************
* Return the Pointer to the DX10 Back Buffer.
******************************************/
inline ID3D10RenderTargetView*	CDX10Manager::getBackBuffer()
{
	return this->_obj_rdr_tgt_view;
}

/******************************************
* Return the Pointer to the DX10 Depth Stencil
* Buffer.
******************************************/
inline ID3D10Texture2D*	CDX10Manager::getDSBuffer()
{
	return this->_obj_depth_stencil_buff;
}

/******************************************
* Return the Pointer to the DX10 Depth Stencil
* View.
******************************************/
inline ID3D10DepthStencilView* CDX10Manager::getDSView()
{
	return this->_obj_depth_stencil_view;
}

/******************************************
* Return the Pointer to the DX10 Rasteriser
* State.
******************************************/
inline ID3D10RasterizerState* CDX10Manager::getRasteriserState()
{
	return this->_obj_raster_state;
}

#endif